﻿using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account;
using Volo.Abp.AutoMapper;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement;
using mozhi.smarterp.AuthorCenter.Users;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System;
using Microsoft.AspNetCore.Identity;

namespace mozhi.smarterp.AuthorCenter;

[DependsOn(
    typeof(AuthorCenterDomainModule),
    typeof(AbpAccountApplicationModule),
    typeof(AuthorCenterApplicationContractsModule),
    typeof(AbpIdentityApplicationModule),
    typeof(AbpPermissionManagementApplicationModule),
    typeof(AbpTenantManagementApplicationModule),
    typeof(AbpFeatureManagementApplicationModule),
    typeof(AbpSettingManagementApplicationModule)
    )]
public class AuthorCenterApplicationModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        PreConfigure<IdentityBuilder>(builder =>
        {
            builder.AddClaimsPrincipalFactory<CustomUserClaimsPrincipalFactory>();
        });
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpAutoMapperOptions>(options =>
        {
            options.AddMaps<AuthorCenterApplicationModule>();
        });

        context.Services.Replace(
            ServiceDescriptor.Transient<IIdentityUserAppService, CustomIdentityUserAppService>()
        );
    }
}
